﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;

using CSJ2K.Jpc;
using CSJ2K.Jp2;
using CSJ2K.Util;
using CSJ2K.Util.IO;

namespace CSJ2K.Jp2
{
    public class Jp2Stream
    {
        public List<Box> Boxes = new List<Box>();

        public Jp2Stream(string Filename)
            : this(new FileStream(Filename, FileMode.Open, FileAccess.Read))
        {
        }
        public Jp2Stream(Stream source)
        {
            while (true)
            {
                try
                {
                    Box box = Box.FromStream(source);
                    Boxes.Add(box);
                }
                catch (EndOfStreamException)
                {
                    if(DEBUG.Jp2File) Debug.WriteLine("End of File");
                    break;
                }
            }
        }
    }
}
